package com.xaicode.template.sqlite3.serviceimpl;

import cn.hutool.core.util.RandomUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xaicode.template.sqlite3.entity.Plane;
import com.xaicode.template.sqlite3.mapper.PlaneMapper;
import com.xaicode.template.sqlite3.service.IPlaneService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xiachangjian <xiachangjian@sataero.cn>
 * @date 2023/2/15
 * @since v2.0.1
 */
@Slf4j
@Service
@DS("base")
public class PlaneServiceImpl extends ServiceImpl<PlaneMapper, Plane> implements IPlaneService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void addOne() {
        Plane plane = new Plane();
        plane.setName(RandomUtil.randomString(6));
        save(plane);
        log.info("plane add [{}]", plane.getId());
    }
}
